package org.domain.sigepac.repository.impl;

import java.util.Collections;
import java.util.List;

import org.domain.sigepac.Entity.Professor;
import org.domain.sigepac.Entity.TipoUsuario;
import org.domain.sigepac.repository.RepositorioGenerico;
import org.domain.sigepac.repository.RepositorioProfessor;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;



/**
 * @author bruno.canto
 */
@Name("repositorioProfessor")
@AutoCreate
public class RepositorioProfessorImpl extends RepositorioGenerico<Professor>
    implements RepositorioProfessor {

	@SuppressWarnings("unchecked")
	public List<Professor> pesquisarPorNome(String nome) {
		try {
			return (List<Professor>) this.entityManager.createQuery(
					"from Usuario as usuario where upper(usuario.nome) like ? and usuario.tipoUsuario=:tipo")
					.setParameter(1,"%"+nome.toUpperCase()+"%")
					.setParameter("tipo", TipoUsuario.PROFESSOR)
					.getResultList();

		} catch (Exception e) {
			return Collections.EMPTY_LIST;
		}
	}


}
